import { Body, Controller, HttpCode, Post } from '@nestjs/common';
import { SmsService } from './sms.service';
import { ISendSMSApiParams, ICheckCaptchaByIDApiParams } from './types';
// import { CreateSmDto } from './dto/create-sm.dto';
// import { UpdateSmDto } from './dto/update-sm.dto';

@Controller('sms')
export class SmsController {
  constructor(private readonly smsService: SmsService) {}
  @Post('sendSms')
  @HttpCode(200)
  async sendSms(@Body() params: ISendSMSApiParams) {
    // const res = await this.userService.batchQueryByIDs(params.IDs.split(','));
    // if (res.length == params.IDs.split(',').length) {
    //   return {
    //     code: '1',
    //     data: res,
    //   };
    // } else {
    //   // throwHttpException({
    //   //   errcode: ErrCode.ParamsError,
    //   //   errmsg: '删除失败！',
    //   //   errstack: '',
    //   // });
    // }
    return await this.smsService.sendSms(params);
  }

  @Post('checkCaptchaByID')
  async checkCaptchaByID(@Body() params: ICheckCaptchaByIDApiParams) {
    return await this.smsService.checkCaptchaByID(params);
  }
}
